function visLattice2D(D, n, q, center, radius, theta, M, type)
%VISLATTICE
    if D ~= 2
        error('Wrong dimension.');
    end
    markerSize = 16;
    pointMargin = 2;
    margin = [-pointMargin, (n+pointMargin)];
    Ticks = linspace(margin(1), margin(2), n+2*pointMargin+1);
    figure; hold on;
    % 1. Plot the ellipse. 
    if type == 'e'
        plotEllipse(center, radius);
    elseif type == 'b'
        plotBox(center, radius, theta);
    else
        error('Unknown test case.');
    end
    % 2. Mark the lattice. 
    M = reshape(M, 2, []);
    plot(M(1,:), M(2,:), 'ko', 'MarkerSize', markerSize, 'MarkerFaceColor', 'k');
    plot(q(1), q(2), 'ko', 'MarkerSize', markerSize, 'MarkerFaceColor', 'w');
    % 3. Set up the view.
    axis equal;
    axis([margin(1) margin(2) margin(1) margin(2)]);
    ax = gca;
    ax.XTick = Ticks;
    ax.YTick = Ticks;
    grid on;
    hold off;
end

